import alg
import gen
import time 
import matplotlib.pyplot as plt
import numpy as np
def test():
    space=[50,100,150,200,250,1000]
    time_0=[]
    time_1=[]
    for i in range(len(space)):
        sum_1=gen.random_int_list_1(space[i])
        sum_2=gen.random_int_list_1(space[i])
        begin=time.time()
        alg.largestNumber(sum_1)
        end=time.time()
        time_0.append((end-begin))
        begin=time.time()
        alg.largestNumber_y(sum_2)
        end=time.time()
        time_1.append((end-begin))
        
    plt.plot(space, time_1, 'b*--', alpha=0.5, linewidth=1, label='DP')#'bo-'表示蓝色实线，数据点实心原点标注
## plot中参数的含义分别是横轴值，纵轴值，线的形状（'s'方块,'o'实心圆点，'*'五角星   ...，颜色，透明度,线的宽度和标签 ，
    plt.plot(space, time_0, 'rs--', alpha=0.5, linewidth=1, label='force')
    plt.legend()  #显示上面的label
    plt.xlabel('data') #x_label
    plt.ylabel('time')#y_label
    plt.show()
    print("force",time_0)
    print("DP",time_1)
test()

def test1():
    space=[1,2,3,4,5,6,7,8,9,10]
    time_0=[]
    for i in range(len(space)):
        sum_1=gen.random_int_list_1(space[i])       
        begin=time.time()
        alg.permute(sum_1)
        end=time.time()
        time_0.append((end-begin))   
    plt.plot(space, time_0, 'rs--', alpha=0.5, linewidth=1, label='hs')
    plt.legend()  #显示上面的label
    plt.xlabel('data') #x_label
    plt.ylabel('time')#y_label
    plt.show()
    print("hs",time_0)

test1()

def test2():
    space=[100,300,500,700,900]
    time_0=[]
    for i in range(len(space)):
        sum_1=gen.random_int_list_1(space[i])       
        begin=time.time()
        alg.lengthOfLIS(sum_1)
        end=time.time()
        time_0.append((end-begin))   
    plt.plot(space, time_0, 'rs--', alpha=0.5, linewidth=1, label='DP')
    plt.legend()  #显示上面的label
    plt.xlabel('data') #x_label
    plt.ylabel('time')#y_label
    plt.show()
    print("DP",time_0)

test2()


